/*
 * Copyright (C) 2012 ZXing authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mylhyl.zxing.scanner.camera;


import ohos.media.camera.CameraKit;
import ohos.media.camera.device.FrameConfig;
import ohos.media.camera.params.Metadata;

import java.util.ArrayList;
import java.util.Collection;

final class AutoFocusManager {

    private static final Collection<Integer> FOCUS_MODES_CALLING_AF;

    static {
        FOCUS_MODES_CALLING_AF = new ArrayList<>(2);
        FOCUS_MODES_CALLING_AF.add(Metadata.AfMode.AF_MODE_CONTINUOUS);
        FOCUS_MODES_CALLING_AF.add(Metadata.AfMode.AF_MODE_TOUCH_LOCK);
    }

    private boolean stopped;
    private boolean focusing;
    private final boolean useAutoFocus;
    private final CameraKit cameraKit;
    private final FrameConfig.Builder builder;

    AutoFocusManager(CameraKit cameraKit, FrameConfig.Builder builder) {

        this.cameraKit = cameraKit;
        this.builder = builder;
        int currentFocusMode = builder.getAfMode();
        // 自动对焦
        useAutoFocus = true && FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
        start();
    }


    synchronized void start() {

    }

    private synchronized void cancelOutstandingTask() {

    }

    synchronized void stop() {
        stopped = true;
        if (useAutoFocus) {
            cancelOutstandingTask();
        }
    }


}
